type Toptions_ONCLICK = {
    /** 点击事件回调方法 */
    onclick?: Tevent_callback;
};

/**
 * 可点击控件注解
 * @param target 目标类型
 */
function AConclick(target: any) {
    if (!U.isSubClass(_CP_, target)) { return; }

    // 处理器
    const original_options_handlers = target.prototype.options_handlers;
    target.prototype.options_handlers = function (this: _CP_<any>) {
        const options_handlers = original_options_handlers.call(this);

        U.O.setDefaultValue(options_handlers, 'onclick', _CP_.OPTIONS_HANDLER.get('function'));

        return options_handlers;
    };

    // 初始化
    const original_afterInitializer = target.prototype.afterInitializer;
    target.prototype.afterInitializer = function (this: _CP_<any>) {
        original_afterInitializer.call(this);

        // 监听点击事件
        if (Object.prototype.hasOwnProperty.call(this.options, 'onclick')) {
            const ele = this.ele;
            ele.on('click', (event) => {
                event.preventDefault();// 阻止默认行为
                event.stopPropagation();// 阻止冒泡
                // 禁用的控件不回调
                if (ele.hasClass(_CP_.CLASSES.DISABLED)) { return; }
                const onclick = ele.ele()!.creator!.options.onclick;
                if (onclick) { onclick.call(ele, event); }
            });
        }
    };
}
